package com.whmnx.home.ui.model;

import android.app.Application;

import androidx.annotation.NonNull;

import com.whmnx.base.bean.TCVideoInfo;
import com.whmnx.base.bean.VideoListBean;
import com.whmnx.base.constants.Constants;
import com.whmnx.base.http.CallBack;
import com.whmnx.base.http.HttpClient;
import com.whmnx.home.databinding.FragmentGuanZhiBinding;
import com.whmnx.home.ui.fragment.TunJianFragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.utils.SPUtils;

/**
 * author : huang
 * date   : 2020/10/24 0024 19:16
 * version: 1.0
 */
public class TouJianModel extends BaseViewModel {

    public List<TCVideoInfo> mTCLiveInfoList  = new ArrayList<>();
    public TunJianFragment mFragment;
    public FragmentGuanZhiBinding mBinding;

    public TouJianModel(@NonNull Application application) {
        super(application);
        initData();
    }


    public void initToolbar(TunJianFragment tunJianFragment, FragmentGuanZhiBinding binding) {
        this.mFragment = tunJianFragment;
        this.mBinding = binding;
    }




    private void initData() {
        Map<String, Object> params = new HashMap<>();
        params.put("uId", SPUtils.getInstance().getString(Constants.USERID));
        params.put("pageIndex", 1);
        params.put("pageSize", 10);
        HttpClient.post(mFragment.getActivity(), Constants.RECOMMENDVIDEOLIST, params,new CallBack<List<VideoListBean>>() {
            @Override
            public void onSuccess(List<VideoListBean> videoListBeans) {
                for (VideoListBean videoListBean : videoListBeans) {
                    TCVideoInfo tcVideoInfo = new TCVideoInfo();
                    tcVideoInfo.playurl = videoListBean.getWork_Vidoe();
                    mTCLiveInfoList.add(tcVideoInfo);
                }

               /* Intent intent = new Intent(mFragment.getActivity(), TCVodPlayerActivity.class);
                intent.putExtra(UGCKitConstants.PLAY_URL, "");
                intent.putExtra(UGCKitConstants.PUSHER_ID, "");
                //  intent.putExtra(UGCKitConstants.PUSHER_NAME, item.nickname == null ? item.userid : item.nickname);
                intent.putExtra(UGCKitConstants.PUSHER_AVATAR, "");
                intent.putExtra(UGCKitConstants.COVER_PIC, "");
                intent.putExtra(UGCKitConstants.FILE_ID, "");
                intent.putExtra(UGCKitConstants.TCLIVE_INFO_LIST, (Serializable) mTCLiveInfoList);
                intent.putExtra(UGCKitConstants.TIMESTAMP, "");
                intent.putExtra(UGCKitConstants.TCLIVE_INFO_POSITION, "");
                mFragment.getActivity().startActivityForResult(intent, 100);*/
            }
        });
    }
}
